#include "../head/HistoryForm_2.h"
#include "ui_historyform_2.h"
#include "../head/mainwindow.h"

HistoryForm_2::HistoryForm_2(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::HistoryForm_2)
{
    ui->setupUi(this);
    this->setWindowTitle("星座图");
    for (int i=0; i<EQ_ALL_ERR_LEN; i++)
    {
        x.append(mutiSignalDecode->EqSig_PriCh_Temp_I[HIGH][i]);
        y.append(mutiSignalDecode->EqSig_PriCh_Temp_Q[HIGH][i]);
    }
    curGraph = ui->customPlot->addGraph();
    curGraph->setLineStyle(QCPGraph::lsNone);
    curGraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 2));
    ui->customPlot->plotLayout()->insertRow(0);
    m_title = new QCPTextElement(ui->customPlot, "星座图");
    ui->customPlot->plotLayout()->addElement(0, 0, m_title);
    curGraph->setData(x, y);
    // 为坐标轴添加标签
    //ui->customPlot->xAxis->setLabel("In-Phase");
    //ui->customPlot->yAxis->setLabel("Quadrature");
    // 设置坐标轴的范围，以看到所有数据
    ui->customPlot->graph(0)->rescaleAxes();
    ui->customPlot->legend->setVisible(false); // 显示图例
    ui->customPlot->replot();
  //  setWindowFlags(Qt::WindowCloseButtonHint|Qt::CustomizeWindowHint|Qt::WindowMaximizeButtonHint);
}

HistoryForm_2::~HistoryForm_2()
{
    delete ui;
}




//关闭窗口回到导航界面
 void HistoryForm_2::closeEvent(QCloseEvent *e)
 {
     //nf->show();
 }


 void HistoryForm_2::drawWaveformPlot(int type)
 {
     for (int i=0; i<EQ_ALL_ERR_LEN; i++)
     {
         x.replace(i,mutiSignalDecode->EqSig_PriCh_Temp_I[type][i]);
         y.replace(i,mutiSignalDecode->EqSig_PriCh_Temp_Q[type][i]);
     }
     curGraph->setData(x, y);
     ui->customPlot->graph(0)->rescaleAxes();
     // 重画图像
     ui->customPlot->replot();
 }
